var isIE = !!document.all;
//Selector
function bindSelector()
{
	for(var i=0; i<arguments.length; i++) {
		document.getElementById(arguments[i]).onmouseover = function(){
			this.getElementsByTagName("ul")[0].style.display = "block";
		}
		document.getElementById(arguments[i]).onmouseout = function(){
			this.getElementsByTagName("ul")[0].style.display = "none";
		}
	}
}

function getStyle(el, name)
{
	return isIE ? el.currentStyle[name] : window.getComputedStyle(el, null)[name];
}
$(function(){
	//获取区
	$.ajax({
		"url":"house/showDistrict",
		"type":"get",
		"dataType":"json",
		"success":function(data){
			data=JSON.parse(data);
			var $select = $("#s-position-o ul select");
			for(var i=0;i<data.length;i++){
				$select.append("<option value='"+data[i].id+"'>"+data[i].name+"</option>");				
			}
		}
	});
	
	//根据不同的区县显示对应的街道
	$("select[name='district_id']").on("change",function(){
		var id=	this.value;
		$.ajax({
			"url":"showStreetById",
			"type":"get",
			"data":"id="+id,
			"dataType":"json",
			"success":callBack
		});
		function callBack(data){
			data=JSON.parse(data);
			$("select[name='street_id']").html(
					function(e){
						var str="";
						for(var i=0;i<data.length;i++){
							str += "<option value="+data[i].id+">"+data[i].name+"</option>";
						}
						if(data.length <=0){
							str ="<option value=''>没有街道</option>";
						}
						return str;
					});
	};
});
	
	/**
	 * 点击图片返回房屋的所有信息
	 */
	function clickHouse(id){
		alert(id);
	}
});